package filterData;

import java.io.File;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import inputData.InputData;

public class FilterData {
	public String[] filterData(String str[]){
		String r = "[\\d]+ [a-zA-Z]+ [a-zA-Z0-9]+@(163|qq).com (girl|boy) \\d{4}-\\d{1,2}-\\d{1,2}";
		Pattern p = Pattern.compile(r);
		
		int count = 0;
		for(int i = 0; i < str.length; i++ ){
			if(str[i] != null){
				Matcher m1 = p.matcher(str[i]);
				if(m1.find()){         //符合条件的数据
					count++;		//数据个数
					continue;
				}
				else{
					str[i] = null;
				}
			}
		}
		
		String[] buf = new String[count];
		int index = 0;
		for(int j = 0; j < str.length; j++){
			if(str[j] != null)
				buf[index++] = str[j];
		}
		return buf;               //数据处理完毕     
	}
}
